#ifndef YOLOV3_H
#define YOLOV3_H

#include <QWidget>
#include <vector>
#include <QCoreApplication>
#include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/dnn.hpp>
#include <fstream>
using namespace std;
//using namespace cv;
//using namespace cv::dnn;

class yolov3 : public QWidget
{
    Q_OBJECT
private:
    float confThreshold = 0.5;
    float nmsThreshold = 0.4;
    int inpWidth = 416;
    int inpHeight = 416;
    QString *modelWeights;
    QString *modelCfg;
    QString *classesFile;
    vector<string> *classes;
    cv::dnn::Net *net;
public:
    explicit yolov3(QWidget *parent = nullptr);
    ~yolov3();
    QString getmodelWeights();
    void setmodelWeights(QString modelWeights);
    QString getmodelCfg();
    void setmodelCfg(QString modelCfg);
    QString getClassesFile();
    void setClassesFile(QString classesFile);
    void setConfidence(double);
    float getConfidence();
    void modifyNet(QString,QString,QString,double);
    void setClasses();
    void postprocess(cv::Mat& frame, const vector<cv::Mat>& out);

    void drawPred(int classId, float conf, int left, int top, int right, int bottom, cv::Mat& frame);

    vector<cv::String> getOutputsNames(const cv::dnn::Net& net);

    void loadNet();
    cv::Mat detect(cv::Mat *frame);

signals:
    void violation(cv::Mat);

};

#endif // YOLOV3_H
